﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_Flight : System.Web.UI.Page
{
    FlightBusiness fb = new FlightBusiness();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
            bindGV();
    }
    public void bindGV()
    {
        GridView1.DataSource = fb.getAllFlight();
        GridView1.DataBind();
    }
    protected void btnAddNew_Click(object sender, EventArgs e)
    {
        Response.Redirect("FlightEdit.aspx?flightID=0");
    }
    protected void lbEdit_Click(object sender, EventArgs e)
    {
        Response.Redirect("FlightEdit.aspx?flightID="+((LinkButton)sender).CommandArgument);
    }
    protected void Delete_Click(object sender, EventArgs e)
    {
        if(fb.Delete(int.Parse(((LinkButton)sender).CommandArgument)))
            Response.Redirect("Flight.aspx");
        else
            Label1.Text="Không xóa được";
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        this.bindGV();
    }
}